package com.zy.utils;

import com.alibaba.fastjson.JSONObject;

/**
 * 
 * @author Administrator
 * 
 */
public class AppJSONUtil {
	public final static String APP_JSON_RESULT_STATE_SUCCESS = "0";
	public final static String APP_JSON_RESULT_STATE_FAIL = "1";
	/**
	 * 初始化相应
	 * @return
	 */
	public static  JSONObject initResp(){
		JSONObject object = new JSONObject();
		return object;
	}
	/**
	 * 发送成功相应
	 * @param resp
	 * @param succMsg 成功消息
	 * @param result
	 * @return
	 */
	public static  JSONObject sendSuccResp(JSONObject resp,String succMsg,Object result){
		resp.put("status", APP_JSON_RESULT_STATE_SUCCESS);
		resp.put("message", succMsg);
		resp.put("result", result);
		return resp;
	}
	
	public static  JSONObject sendSuccResp(JSONObject resp,String succMsg){
		resp.put("status", APP_JSON_RESULT_STATE_SUCCESS);
		resp.put("message", succMsg);
		resp.put("result", "");
		return resp;
	}
	
	/**
	 * 发送失败相应
	 * @param resp
	 * @param succMsg 成功消息
	 * @param result
	 * @return
	 */
	public static  JSONObject sendFailResp(JSONObject resp,String failMsg,Object result){
		resp.put("status", APP_JSON_RESULT_STATE_FAIL);
		resp.put("message", failMsg);
		resp.put("result", result);
		return resp;
	}
	
	public static  JSONObject sendFailResp(JSONObject resp,String failMsg){
		resp.put("status", APP_JSON_RESULT_STATE_FAIL);
		resp.put("message", failMsg);
		resp.put("result", "");
		return resp;
	}
	
	
}
